<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:pe="http://primefaces.org/ui/extensions">

    <h:body>

        <ui:composition template="/resources/template/template.xhtml">



            <ui:define name="content">
                <h:outputStylesheet library="css" name="printing.css" />

                <h:form>
                    <p:panel  styleClass="tem nonPrintBlock"  >
                        <f:facet name="header">
                        <h:outputLabel styleClass="noPrintButton"  value="Income Report" />
                         </f:facet>
                        <h:panelGrid columns="2">

                            <h:outputLabel value="From Date" />  
                            <p:calendar styleClass="noPrintButton" value="#{labReportSearchByDepartmentController.fromDate}" pattern="dd MMMM yyyy hh:mm:ss a" >
                            </p:calendar>
                             <h:outputLabel value="To Date" /> 
                            <p:calendar styleClass="noPrintButton" value="#{labReportSearchByDepartmentController.toDate}" pattern="dd MMMM yyyy hh:mm:ss a" >
                            </p:calendar>
                            <h:outputLabel styleClass="noPrintButton" value="Department" style="text-align: left; margin: 0px; padding: 0px;" ></h:outputLabel>
                            <p:autoComplete styleClass="noPrintButton"  value="#{labReportSearchByDepartmentController.department}"  style="text-align: left; margin: 0px; padding: 0px;"  completeMethod="#{departmentController.completeDept}" var="dept" itemValue="#{dept}" itemLabel="#{dept.name}" forceSelection="true" rendered="true" requiredMessage="You must select a department" >
                            </p:autoComplete>
                              </h:panelGrid>
                              <h:panelGrid columns="5">
                                  <p:spacer width="70" height="1"/>
                            <p:commandButton id="btnRefresh" styleClass="noPrintButton" value="Refresh" ajax="false" />
                            <p:defaultCommand target="btnRefresh"/>
                            <p:commandButton styleClass="noPrintButton" value="Print" ajax="false" >
                                <p:printer target="panelReport" />
                            </p:commandButton>             
                            <p:commandButton value="Excel" ajax="false">
                                <pe:exporter type="xlsx" target="tbl" fileName="PlayersStatistics"
                                             facetBackground="#008000" facetFontSize="15" 
                                             facetFontColor="#FFFFFF" facetFontStyle="BOLD" cellFontColor="#0000FF" cellFontSize="12"  cellFontStyle="NORMAL"  
                                             fontName="Courier New" />
                            </p:commandButton>
                        </h:panelGrid>
                       
                    </p:panel>
                    <p:panel id="panelReport" styleClass="noBorder summeryBorder" >

                        <p:dataTable id="tbl" value="#{labReportSearchByDepartmentController.labBillsWithoutOwn}" rowIndexVar="i" var="b" sortBy="#{b.billClass}"  >
                            <f:facet name="header">
                                <h:outputLabel value="Income Report Without Credit By Department - "/>
                                <h:outputLabel value=" #{labReportSearchByDepartmentController.department.name}"/>
                                 <h:outputLabel value="From : " style="white-space: pre-line"/>
                                <h:outputLabel value="#{labReportSearchByDepartmentController.fromDate}"  >
                                    <f:convertDateTime pattern="dd MMMM yyyy hh:mm:ss a" />
                                </h:outputLabel>
                                <h:outputLabel value="&emsp; &emsp;To : "  />
                                <h:outputLabel value="#{labReportSearchByDepartmentController.toDate}" >
                                    <f:convertDateTime pattern="dd MMMM yyyy hh:mm:ss a" />
                                </h:outputLabel>
                            </f:facet>
                            <p:column>
                                <h:outputLabel value="#{i+1}"/>  
                            </p:column>

                            <p:column headerText="Bill Id" >
                                <f:facet name="header">
                                    <h:outputLabel value="Bill Id"/>
                                </f:facet>
                                <h:outputLabel value="#{b.insId}" rendered="#{b.billClass eq 'class com.divudi.entity.BilledBill'}" />
                                <h:outputLabel value="#{b.billedBill.insId}" rendered="#{b.billClass ne 'class com.divudi.entity.BilledBill'}"/>
                            </p:column>

                            <p:column headerText="Name" >
                                <f:facet name="header">
                                    <h:outputLabel value="Name"/>
                                </f:facet>
                                <h:outputLabel value="#{b.patient.person.name}"    ></h:outputLabel>
                            </p:column>

                            <p:column headerText="Hospital Fee" style="text-align: right;" >
                                <f:facet name="header">
                                    <h:outputLabel value="Hospital Fee"/>
                                </f:facet>
                                <h:outputLabel value="#{b.total - b.staffFee}"    >
                                    <f:convertNumber pattern="#,##0.00" />
                                </h:outputLabel>
                            </p:column>

                            <p:column headerText="Dis." style="text-align: right;" >
                                <f:facet name="header">
                                    <h:outputLabel value="Dis."/>
                                </f:facet>
                                <h:outputLabel value="#{b.discount}"   >
                                    <f:convertNumber pattern="#,##0.00" />
                                </h:outputLabel>
                            </p:column>

                            <p:column headerText="Prof. Fee" style="text-align: right;"  >
                                <f:facet name="header">
                                    <h:outputLabel value="Prof. Fee"/>
                                </f:facet>
                                <h:outputLabel value="#{b.staffFee}"   >
                                    <f:convertNumber pattern="#,##0.00" />
                                </h:outputLabel>
                            </p:column>

                            <p:column headerText="Net Total"  style="text-align: right;" >
                                <f:facet name="header">
                                    <h:outputLabel value="Net Total"/>
                                </f:facet>
                                <h:outputLabel value="#{b.netTotal}"  >
                                    <f:convertNumber pattern="#,##0.00" />
                                </h:outputLabel>
                            </p:column>

                            <p:summaryRow >
                                <p:column colspan="3" >
                                    <h:outputLabel value="Billed Bill Totals" rendered="#{b.billClass eq 'class com.divudi.entity.BilledBill'}"/>                                   
                                    <h:outputLabel value="Cancelled Bill Totals" rendered="#{b.billClass eq 'class com.divudi.entity.CancelledBill'}"/>                                 
                                    <h:outputLabel value="Refund Bill Totals" rendered="#{b.billClass eq 'class com.divudi.entity.RefundBill'}"/>
                                </p:column>

                                <p:column  >                                    
                                    <h:outputLabel value="#{labReportSearchByDepartmentController.hosTotB}" rendered="#{b.billClass eq 'class com.divudi.entity.BilledBill'}" style="text-align: right;" >
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>

                                    <h:outputLabel value="#{labReportSearchByDepartmentController.hosTotC}" rendered="#{b.billClass eq 'class com.divudi.entity.CancelledBill'}" >
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>

                                    <h:outputLabel value="#{labReportSearchByDepartmentController.hosTotR}" rendered="#{b.billClass eq 'class com.divudi.entity.RefundBill'}" >
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>                                    
                                </p:column>

                                <p:column  >

                                    <h:outputLabel value="#{labReportSearchByDepartmentController.disTotB}"  rendered="#{b.billClass eq 'class com.divudi.entity.BilledBill'}" >
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>

                                    <h:outputLabel value="#{labReportSearchByDepartmentController.disTotC}" rendered="#{b.billClass eq 'class com.divudi.entity.CancelledBill'}">
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>

                                    <h:outputLabel value="#{labReportSearchByDepartmentController.disTotR}" rendered="#{b.billClass eq 'class com.divudi.entity.RefundBill'}" >
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                </p:column>

                                <p:column  >
                                    <h:outputLabel value="#{labReportSearchByDepartmentController.profTotB}" rendered="#{b.billClass eq 'class com.divudi.entity.BilledBill'}" >
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>

                                    <h:outputLabel value="#{labReportSearchByDepartmentController.profTotC}" rendered="#{b.billClass eq 'class com.divudi.entity.CancelledBill'}" >
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>

                                    <h:outputLabel value="#{labReportSearchByDepartmentController.profTotR}"  rendered="#{b.billClass eq 'class com.divudi.entity.RefundBill'}">
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                </p:column>

                                <p:column  >
                                    <h:outputLabel value="#{labReportSearchByDepartmentController.netTotB}" rendered="#{b.billClass eq 'class com.divudi.entity.BilledBill'}" >
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>

                                    <h:outputLabel value="#{labReportSearchByDepartmentController.netTotC}" rendered="#{b.billClass eq 'class com.divudi.entity.CancelledBill'}" >
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>

                                    <h:outputLabel value="#{labReportSearchByDepartmentController.netTotR}"  rendered="#{b.billClass eq 'class com.divudi.entity.RefundBill'}" >
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                </p:column>

                            </p:summaryRow>

                            <f:facet name="footer" >
                                <p:row>
                                    <h:panelGrid columns="2" style="text-align: right;">
                                        <h:outputLabel  value="Gross Fee Total" ></h:outputLabel>
                                        <h:outputLabel value="#{labReportSearchByDepartmentController.hosTot + labReportSearchByDepartmentController.profTot }" style="text-align: right;" >
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                        <h:outputLabel value="Discount Total" ></h:outputLabel>
                                        <h:outputLabel value="#{labReportSearchByDepartmentController.disTot}" >
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                        <h:outputLabel value="Net Fee Total" ></h:outputLabel>
                                        <h:outputLabel value="#{labReportSearchByDepartmentController.netTot}" >                                        
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                        <h:outputLabel value="Professional Fee Total" ></h:outputLabel>
                                        <h:outputLabel value="#{labReportSearchByDepartmentController.profTot}" style="text-align: right;" >
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                        <h:outputLabel value="" ></h:outputLabel>
                                        <h:outputLabel value="" ></h:outputLabel>
                                        <h:outputLabel style="font-weight: bolder; " value="Net Department Income"/>
                                        <h:outputLabel style="font-weight: bolder; " value="#{labReportSearchByDepartmentController.labHandover}" >
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </h:panelGrid>
                                </p:row>
                            </f:facet>
                <f:facet name="footer" >
                    <h:outputLabel value="Printed By : #{sessionController.loggedUser.webUserPerson.name}" style="float: right"/>
                </f:facet>
                        </p:dataTable>

                    </p:panel>

                </h:form>
            </ui:define>



        </ui:composition>

    </h:body>
</html>
